import request from '@/utils/request'

// 用户登录
export const loginUser = ({ email, password }) => {
  return request({
    url: '/user/login',
    method: 'post',
    data: {
      email,
      password
    }
  })
}

// 用户注册
export const registerUser = ({ email, nickname, password, rePassword }) => {
  return request({
    url: '/users',
    method: 'post',
    data: {
      email,
      nickname,
      password,
      rePassword
    }
  })
}

// 获取当前用户信息
export const getUserInfo = () => {
  return request({
    url: '/user/current',
    method: 'get'
  })
}

// 修改当前用户信息
export const updateUserInfo = ({ id, nickname, description, avatar }) => {
  return request({
    url: '/user',
    method: 'patch',
    data: {
      id,
      nickname,
      description,
      avatar
    }
  })
}
